﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace MyRaceGame.GameLogic
{
    public class TimeCountedRacer : RacerDecorator
    {
        public TimeCountedRacer(RacerCharacter racerCharacter, RaceController raceData)
            : base(racerCharacter)
        {
            this.raceData = raceData;
        }

        protected override void ExtraUpdate(GameTime gameTime)
        {
            totalTime += gameTime.ElapsedGameTime;
        }

        public override void Update(GameTime gameTime)
        {
            if (!raceData.HasFinishedRace(this) || raceData.FreeRace)
                base.Update(gameTime);
        }

        public TimeSpan TotalTime
        {
            get { return totalTime; }
            set { totalTime = value; }
        }

        TimeSpan totalTime;
        RaceController raceData;
    }
}
